package cn.wm.client;

import cn.hutool.log.Log;
import cn.hutool.log.StaticLog;
import cn.wm.struct.Message;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * ClientHandler
 *
 * @author wm
 * @version 1.0
 * 2021/6/25 15:25
 **/
public class ClientHandler extends SimpleChannelInboundHandler<Message> {

    private final static Log log = StaticLog.get();

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Message message) throws Exception {
        log.info("Client receive message from server: " + message);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
            throws Exception {
        log.error("----------客户端数据读异常-----------");
        ctx.close();
    }
}
